// createRouter: 创建router实例对象(new操作)
// createWebHistory: 创建history模式的路由对象

import { createRouter, createWebHistory } from 'vue-router'
import Layout from '@/views/Layout'
import Home from '@/views/Home'
import PlayGround from '@/views/Playground'

const routes = [
  {
    path: '/',
    component: Layout,
    children: [
      {
        path: '', // path置空的时候 当前二级路由组件会当成一级路由的默认渲染组件
        component: Home
      }
    ]
  },
  {
    path: '/play',
    component: PlayGround
  }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL), // 路由模式切换需要调用方法
  routes
})

// 导出路由实例
export default router
